import App from './App'
import uviewPlus from 'uview-plus'
import { createSSRApp } from 'vue'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'

//  wx9848b877076fb0dd 帅果科技
//  wx995d8509be9264b5 0507商城
//  wxde913dac5550a611 华靓甄选
// 条件编译：微信小程序
// #ifdef MP-WEIXIN
uni.appId = 'wxde913dac5550a611';
// #endif

// 条件编译：支付宝小程序
// #ifdef MP-ALIPAY
uni.appId = '2021002129616028';
// #endif

export function createApp() {
	const pinia = createPinia()
	const app = createSSRApp(App)

	pinia.use(
		createPersistedState({
			key: (key) => `__persisted__${key}`,
			storage: {
				setItem(key, value) {
					// 定义如何存数据
					uni.setStorageSync(key, value)
				},
				getItem(key) {
					// 定义如何取数据
					return uni.getStorageSync(key)
				}
			}
		})
	)

	app.use(pinia)
	app.use(uviewPlus)
	return {
		app
	}
}